package com.powernode.spring6.service.Impl;

import com.powernode.spring6.dao.AccountDao;
import com.powernode.spring6.pojo.Account;
import com.powernode.spring6.service.AccountService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("accountService2")
public class AccountServiceImpl2 implements AccountService {
    @Resource(name = "accountDao")
    private AccountDao accountDao;

    @Override
    public void transfer(String fromActNo, String toActNo, Double balance) {

    }

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void save(Account act) {
        // 调用accountDao中的save方法
        accountDao.insert(act);

        // 模拟异常
        /*String s = null;
        s.toString();*/

        // 事儿没有处理完，这个大括号当中的后续也许还有其他的DML语句。
    }
}
